package com.kfpanda.search.biz.searchmg;

import java.io.BufferedReader;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStreamReader;

import org.apache.log4j.Logger;
import org.springframework.stereotype.Service;

import com.kfpanda.search.biz.BaseBIZ;
import com.util.common.encoding.FileCode;

@Service("fileBIZ")
public class FileBIZ extends BaseBIZ {
	private Logger logger = Logger.getLogger(FileBIZ.class);

	public String fileDetail(String filePath) {
		String fileContent = "";
		try {
			FileInputStream fis = new FileInputStream(new File(filePath));
			String streamCode = FileCode.guestStreamEncoding(fis);
			BufferedReader reader = new BufferedReader(new InputStreamReader(
					fis, streamCode));
			String line = "";
			while ((line = reader.readLine()) != null) {
				fileContent += line;
			}
			reader.close();
		} catch (IOException e) {
			e.printStackTrace();
		}finally{
			//TODO 文件关闭处理
		}
		return fileContent;
	}
}
